<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>

<% String ctxPath = request.getContextPath(); %>

<script language="JavaScript">
  
  function doCancel() {
    self.close();
  }
  
  function doValueUpdate() {
    callParentWindowUpdate(document.portletEntityPreferenceForm.oldValue.value,document.portletEntityPreferenceForm.preferenceValue.value);
  }
  
  function callParentWindowUpdate(oldValue,preferenceValue) {
    if (self.opener != null) {
      self.opener.<c:out value="${portletEntityPreferenceValueForm.map.callback}"/>(oldValue,preferenceValue);
    }
    self.close();
  }

  function doValueAdd() {
    callParentWindowAdd(document.portletEntityPreferenceForm.preferenceValue.value);
  }
  
  function callParentWindowAdd(preferenceValue) {
    if (self.opener != null) {
      self.opener.<c:out value="${portletEntityPreferenceValueForm.map.callback}"/>(preferenceValue);
    }
    self.close();
  }

  function doValueSubmit() {
    if(document.portletEntityPreferenceForm.preferenceValue.value == '') {
      alert('<bean:message key='ep.alert.empty.portlet.entity.preference.value' bundle="ep.messages"/>');
      return false;
    }

    var tmp_string = document.portletEntityPreferenceForm.preferenceValue.value;
    for (var i=0; i < tmp_string.length; i++) {
      if(tmp_string.substring(i, i+1) != " ") {
      <c:if test="${portletEntityPreferenceValueForm.map.preferenceValue == ''}">
        doValueAdd();
      </c:if>
      <c:if test="${portletEntityPreferenceValueForm.map.preferenceValue != ''}">
        doValueUpdate();
      </c:if>
        return false;
      }
    }
    alert('<bean:message key='ep.alert.portlet.entity.preference.value.all.spaces' bundle="ep.messages"/>');
    return false;
  }
  
</script>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
      <c:if test="${portletEntityPreferenceValueForm.map.preferenceValue == ''}">
        <bean:message key="ep.portlet.entity.preference.value.new.page.title" bundle="ep.messages"/>
      </c:if>
      <c:if test="${portletEntityPreferenceValueForm.map.preferenceValue != ''}">
        <bean-el:message key="ep.portlet.entity.preference.value.edit.page.title" bundle="ep.messages" arg0="${portletEntityPreferenceForm.map.preferenceName}"/>
      </c:if>
      </div>
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>

      <!- place body here -->

      <html-el:form action="/ep/portletEntityPreferenceEdit.do" onsubmit="return doValueSubmit();">

      <html-el:hidden property="oldValue" value="${portletEntityPreferenceValueForm.map.preferenceValue}"/>
      <html-el:hidden property="callback" value="${portletEntityPreferenceValueForm.map.callback}"/>
      
      <input type="hidden" name="forward" value="<c:out value="${epActionForward.map.forward}"/>">

      <div class="pageSubtitle">
        <span class="left"><bean:message key="ep.portlet.entity.preference.value.information" bundle="ep.messages"/></span>
        <span class="right">&nbsp;</span>
      </div>

      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="label"><bean:message key="ep.portlet.entity.preference.value" bundle="ep.messages"/>*:</td>
        <td class="labelField"><input type="text" name="preferenceValue" value="<c:out value="${portletEntityPreferenceValueForm.map.preferenceValue}"/>" size="50" maxlength="80"/>
        </td>
      </tr>
      
      </table>

      <div class="pageButtonWrap" align="right">
        <input type="reset" name="resetBtn" value="<bean:message key='button.reset' bundle="ep.messages"/>" class="inputButton">
        &nbsp;&nbsp;
        <input type="button" name="cancelData" class="inputButton" value="<bean:message key='button.cancel' bundle="ep.messages"/>" onclick="doCancel();">
        <input type="submit" name="saveData" class="inputButton" value="<bean:message key='button.save' bundle="ep.messages"/>">
      </div>
      
      </html-el:form>
    </td>
  </tr>      
</table>
